<template>
  <div class="label-progress">
    <div class="left">
      <div class="label">{{ label }}</div>
      <el-progress
        :stroke-width="8"
        :show-text="false"
        :percentage="percentage || 0"
        :color="color"
      ></el-progress>
    </div>
    <div class="value">{{ value }}</div>
  </div>
</template>

<script>
export default {
  props: {
    label: {
      type: String,
      required: true
    },
    value: {
      type: [String, Number],
      required: true
    },
    total: {
      type: [String, Number],
      required: true
    },
    color: {
      type: String,
      default: ""
    }
  },
  computed: {
    percentage() {
      try {
        const p = (parseInt(this.value) / parseInt(this.total)) * 100;
        return p;
      } catch (e) {
        return 0;
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.label-progress {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  .left {
    width: 180px;
  }
  .label {
    margin-bottom: 6px;
    font-size: 14px;
  }
  .value {
    color: #333c48;
    font-size: 24px;
  }
}
</style>
